export {
  uniGetSetting,
  uniOpenSetting,
  uniChooseLocation,
  uniShowToast,
  uniGetUserInfo,
  uniLogin,
  uniGetProvider,
  uniRequestPayment,
}

/* 获取设置 */
const uniGetSetting = function uniGetSetting() {
  var res = new Promise(function(resolve, reject) {
    uni.getSetting({
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 打开设置 */
const uniOpenSetting = function uniOpenSetting() {
  var res = new Promise(function(resolve, reject) {
    uni.openSetting({
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 选择地址 */
const uniChooseLocation = function uniChooseLocation() {
  var res = new Promise(function(resolve, reject) {
    uni.chooseLocation({
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 显示提示框 */
const uniShowToast = function uniShowToast(params) {
  var res = new Promise(function(resolve, reject) {
    uni.showToast({
      ...params,
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 获取用户信息 */
const uniGetUserInfo = function uniGetUserInfo(params) {
  var res = new Promise(function(resolve, reject) {
    uni.getUserInfo({
      ...params,
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 登录 */
const uniLogin = function uniLogin(params) {
  var res = new Promise(function(resolve, reject) {
    uni.login({
      ...params,
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 获取服务供应商 */
const uniGetProvider = function uniGetProvider(params) {
  var res = new Promise(function(resolve, reject) {
    uni.getProvider({
      ...params,
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

/* 支付 */
const uniRequestPayment = function uniRequestPayment(params) {
  var res = new Promise(function(resolve, reject) {
    uni.requestPayment({
      ...params,
      success(success) {
        resolve(success)
      },
      fail(fail) {
        reject(fail)
      }
    });
  })
  return res
}

